﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Oragon.Architecture.Data.SqlBuilder
{
	[Serializable]
	public enum Sorting
	{
		Ascending,
		Descending
	}

	/// <summary>
	/// Representa um item da cláusula Order By
	/// </summary>
	[Serializable]
	public class OrderByItem : ISQLStatement
	{
		public Sorting Sorting { get; set; }
		public string ColumnName { get; set; }

		public OrderByItem() { }

		public OrderByItem(string columnName, Sorting sorting)
		{
			this.ColumnName = columnName;
			this.Sorting = sorting;
		}

		#region ISQLStatement Members

		public string ToSQL()
		{
			if (this.Sorting == Sorting.Ascending)
				return string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0} ASC", this.ColumnName);
			else if (this.Sorting == Sorting.Descending)
				return string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0} DESC", this.ColumnName);
			else
				return string.Empty;
		}

		#endregion
	}
}
